
<script>
	import * as API from "./api/index.js"
	import * as websoket from "@/api/webSocket.js"
	import * as uniPush from "@/api/uniPush.js"
	import {version}  from "@/api/version.js"
	export default {
		onLaunch: function(ev) {
			let that=this
			// #ifndef APP-PLUS
			uni.setStorageSync("DeviceId","123456")  //设备id暂时先写死,后期上线再进行修改
			// #endif
			// //------------------------------------------------获取设备信息------------------------------------------------
			plus.device.getInfo({
				success:function(e){
					// #ifdef APP-PLUS
					uni.setStorageSync("clientid",plus.push.getClientInfo().clientid)
					// #endif
					uni.setStorageSync("DeviceId",e.uuid)
					websoket.connect()
					uniPush.connect()
				},
				fail:function(e){
					// #ifdef APP-PLUS
					uni.setStorageSync("clientid",plus.push.getClientInfo().clientid)
					// #endif
					uni.setStorageSync("DeviceId",e.uuid)
					websoket.connect()
					uniPush.connect()
				},
			})
           //------------------------------------------------检查登录------------------------------------------------

			uni.onTabBarMidButtonTap(function(e) {
				uni.navigateTo({
					url: '/pages/scan'
				});
			});
			 // #ifdef APP-PLUS
			plus.screen.lockOrientation("portrait-primary");
			
			//TODO:检查登录状态
			
			//TODO:绑定推送标识
			plus.push.getClientInfoAsync(function(clnt){
			});
			// #endif
		     // #ifdef APP-PLUS
			//注册图标字体
			let domModule = weex.requireModule('dom');
			               domModule.addRule('fontFace',{
			                 'fontFamily': "flash-icon",	
			                 'src': "url('https://at.alicdn.com/t/font_1806054_iq6uadd41nc.ttf')"
			               })
			// #endif	
		},
		onShow: function(ev) {
			//------------------------------------------------检查版本更新------------------------------------------------
				version()	 
				
		   //------------------------------------------------app二次唤醒------------------------------------------------
				 
			uni.setStorageSync("clientid",plus.push.getClientInfo().clientid)
			if("scheme"===plus.runtime.launcher){
				//是第三方App拉起
				if(!this.globalData.Env.Launcher){
					//首次拉起
					this.globalData.Env.Launcher=plus.runtime.launcher;
					console.log('new scheme in',ev,plus.runtime.arguments);
				}else{
					console.log('re show',ev,plus.runtime.arguments);
				}
				// #ifdef APP-PLUS
				plus.runtime.arguments='';
				// #endif		   
			}
			var Intent = plus.android.importClass('android.content.Intent');
			var mainActivity = plus.android.runtimeMainActivity();  
			var intent = mainActivity.getIntent();
			var token = intent.getStringExtra("token");
		},
		onHide: function() {
			
		},
		onUnload:function(){
			uni.closeSocket();  
		},
		globalData: {
			Env: {
				//环境变量
				NavHeight:null,
				FullHeight:null,
				Plate:'',
				Launcher:null
			},
			Ord: {
				//当前订单
			}
		}
	}
</script>

<style>
     @import url("https://at.alicdn.com/t/font_1806054_iq6uadd41nc.css");
</style>
